package cn.cq.admin.controller;

import cn.cq.admin.entity.dto.BatchRemove;
import cn.cq.admin.entity.dto.CoursewareDto;
import cn.cq.admin.entity.model.Courseware;
import cn.cq.admin.entity.vo.CoursewareVo;
import cn.cq.admin.entity.vo.TreeVo;
import cn.cq.admin.service.CoursewareService;
import cn.cq.common.BaseConst;
import cn.dev33.satoken.util.SaResult;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/courseware")
public class CoursewareController {
    @Resource
    private CoursewareService coursewareService;
    @PostMapping("/doList")
    public SaResult doList(@RequestBody CoursewareDto coursewareDto) {
        Page<CoursewareVo> coursewareVoPage = coursewareService.doList(coursewareDto);
        return SaResult.data(coursewareVoPage);
    }
    @PostMapping("/doSave")
    public SaResult doSave(@RequestBody Courseware courseware) {
        coursewareService.doSave(courseware);
        return SaResult.ok("新增成功");
    }
    @DeleteMapping("/doRemove")
    public SaResult doRemove(@RequestBody BatchRemove batchRemove) {
        coursewareService.doRemove(batchRemove.getIds());
        return SaResult.ok("删除成功");
    }
    @PutMapping("/doModify")
    public SaResult doModify(@RequestBody Courseware courseware) {
        coursewareService.doModify(courseware);
        return SaResult.ok("修改成功");
    }
    @GetMapping("/doListCourseAndWareByUserId")
    public SaResult doListCourseAndWareByUserId() {
        List<TreeVo> courseAndWare = coursewareService.doListCourseAndWareByUserId();
        return SaResult.data(courseAndWare);
    }
}
